<?php

namespace app\home\controller;

use app\common\model\AuthRuleSon as AuthRuleSonModel;
use app\common\model\UserTypeSon as UserTypeSonModel;

/**
 * 子菜单控制器
 * Class Authruleson
 * @package app\admin\controller
 */
class Authruleson extends Base
{
    /**
     * [giveaccess 获取权限]
     * @return [type] [description]
     * @author [C。]
     */
    public function getaccess()
    {
        $param = input('param.');
        $node = new AuthRuleSonModel();
        if(empty($param['id'])){
            $param['id'] = 1;
        }
        //获取现在的权限
        $nodeStr = $node->getNode($param['id']);

        return admin_json(1, 'success', $nodeStr);
    }
    /**
     * [giveAccess 分配权限]
     * @return [type] [description]
     * @author [C。]
     */
    public function editaccess()
    {
        $param = input('param.');
        $doparam = [
            'id' => $param['id'],
            'rules' => $param['rule']
        ];
        $user1 = new UserTypeSonModel();
        $res = $user1->editAccess($doparam);

        return admin_json(1,'角色权限分配成功');
    }
}